set(SOURCES
    abortrendercommand.cpp
    abstractroidataprinter.cpp
    ambientvoxelshader.cpp
    anatomicalplane.cpp
    anatomicalplanesynccriterion.cpp
    anatomicalregionsynccriterion.cpp
    anglebetweenplanessynccriterion.cpp
    angletool.cpp
    anyinputsynccriterion.cpp
    applicationstylehelper.cpp
    applicationupdatechecker.cpp
    applicationversionchecker.cpp
    applicationversiontest.cpp
    applyhangingprotocolqviewercommand.cpp
    areameasurecomputer.cpp
    arrowtool.cpp
    automaticsynchronizationtool.cpp
    automaticsynchronizationtooldata.cpp
    blendfilter.cpp
    bodysurfaceareaformula.cpp
    bodysurfaceareaformulacalculator.cpp
    changephaseqviewercommand.cpp
    changesliceqviewercommand.cpp
    circletool.cpp
    clippingplanestool.cpp
    colortransferfunction.cpp
    computezspacingpostprocessor.cpp
    contourvoxelshader.cpp
    coresettings.cpp
    createinformationmodelobject.cpp
    cursor3dtool.cpp
    cursor3dtooldata.cpp
    customwindowlevelsloader.cpp
    customwindowlevelsreader.cpp
    customwindowlevelsrepository.cpp
    customwindowlevelswriter.cpp
    decaycorrectionfactorformula.cpp
    decaycorrectionfactorformulacalculator.cpp
    defaultmeasurementtypeselector.cpp
    defaultsettings.cpp
    defaulttransferfunctionselector.cpp
    diagnosistestproblem.cpp
    diagnosistestresult.cpp
    diagnosistestresultwriter.cpp
    dicomattribute.cpp
    dicomdumpdefaulttags.cpp
    dicomdumpdefaulttagsloader.cpp
    dicomdumpdefaulttagsreader.cpp
    dicomdumpdefaulttagsrepository.cpp
    dicomdumpdefaulttagsrestriction.cpp
    dicomfileclassifierfillerstep.cpp
    dicomfilegenerator.cpp
    dicomformattedvaluesconverter.cpp
    dicomimagefilegenerator.cpp
    dicomsequenceattribute.cpp
    dicomsequenceitem.cpp
    dicomserviceresponsestatus.cpp
    dicomsource.cpp
    dicomtag.cpp
    dicomtagreader.cpp
    dicomvalueattribute.cpp
    dicomvaluerepresentationconverter.cpp
    dicomwriter.cpp
    dicomwriterdcmtk.cpp
    directilluminationvoxelshader.cpp
    directoryutilities.cpp
    displayableid.cpp
    displayshutter.cpp
    distancemeasurecomputer.cpp
    distancetool.cpp
    drawer.cpp
    drawerarrow.cpp
    drawerbitmap.cpp
    drawercrosshair.cpp
    drawerline.cpp
    drawerpoint.cpp
    drawerpolygon.cpp
    drawerpolyline.cpp
    drawerprimitive.cpp
    drawertext.cpp
    dynamicmatrix.cpp
    editortool.cpp
    editortooldata.cpp
    ellipticalroitool.cpp
    encapsulateddocument.cpp
    encapsulateddocumentfillerstep.cpp
    erasertool.cpp
    extensioncontext.cpp
    extensionmediator.cpp
    externalapplication.cpp
    externalapplicationsmanager.cpp
    filter.cpp
    filteroutput.cpp
    formula.cpp
    formulacalculator.cpp
    frameofreferencesynccriterion.cpp
    genericdistancetool.cpp
    genericvolumedisplayunithandler.cpp
    glutessellator.cpp
    gridicon.cpp
    griditerator.cpp
    hangingprotocol.cpp
    hangingprotocoldisplayset.cpp
    hangingprotocolfiller.cpp
    hangingprotocolimageset.cpp
    hangingprotocolimagesetrestriction.cpp
    hangingprotocolimagesetrestrictionexpression.cpp
    hangingprotocollayout.cpp
    hangingprotocolmanager.cpp
    hangingprotocolmask.cpp
    hangingprotocolsloader.cpp
    hangingprotocolsrepository.cpp
    hangingprotocolxmlreader.cpp
    harddiskinformation.cpp
    hoverpoints.cpp
    identifier.cpp
    image.cpp
    imagefillerstep.cpp
    imageorientation.cpp
    imageorientationoperationsmapper.cpp
    imageorientationsignaltosyncactionmapper.cpp
    imageorientationsyncaction.cpp
    imageoverlay.cpp
    imageoverlayreader.cpp
    imageoverlayregionfinder.cpp
    imagepipeline.cpp
    imageplane.cpp
    itemmenu.cpp
    keyimagenotefillerstep.cpp
    leanbodymassformula.cpp
    leanbodymassformulacalculator.cpp
    line3d.cpp
    logging.cpp
    loggingoutputwindow.cpp
    machineidentifier.cpp
    machineinformation.cpp
    magicroitool.cpp
    magnifyingglasstool.cpp
    maininputsynccriterion.cpp
    mammographyimagehelper.cpp
    mathtools.cpp
    measurecomputer.cpp
    measurementmanager.cpp
    measurementtool.cpp
    messagebus.cpp
    modalitysynccriterion.cpp
    nmctfusionroidataprinter.cpp
    nmctvolumedisplayunithandler.cpp
    nmroidataprinter.cpp
    nmvolumedisplayunithandler.cpp
    nonclosedangletool.cpp
    nondicomfileclassifierfillerstep.cpp
    opacitytransferfunction.cpp
    optimalviewersgridestimator.cpp
    orderimagesfillerstep.cpp
    orthogonalplane.cpp
    pacsdevice.cpp
    pairedvolumedisplayunithandler.cpp
    pansignaltosyncactionmapper.cpp
    pansyncaction.cpp
    patient.cpp
    patientbrowsermenu.cpp
    patientbrowsermenubasicitem.cpp
    patientbrowsermenuextendedinfo.cpp
    patientbrowsermenuextendeditem.cpp
    patientbrowsermenufusionitem.cpp
    patientbrowsermenugroup.cpp
    patientbrowsermenulist.cpp
    patientcomparer.cpp
    patientfiller.cpp
    patientfillerinput.cpp
    patientfillerstep.cpp
    patientorientation.cpp
    persistentsettings.cpp
    perpendiculardistancetool.cpp
    petctfusionroidataprinter.cpp
    petctvolumedisplayunithandler.cpp
    petroidataprinter.cpp
    petvolumedisplayunithandler.cpp
    phasefilter.cpp
    phasesignaltosyncactionmapper.cpp
    phasesyncaction.cpp
    photometricinterpretation.cpp
    pixelspacing2d.cpp
    pixelspacingamenderpostprocessor.cpp
    pixelspacingschemepropertyselector.cpp
    point3d.cpp
    polylineroitool.cpp
    polylinetemporalroitool.cpp
    polylinetemporalroitooldata.cpp
    postprocessor.cpp
    preferredpixelspacingselector.cpp
    presentationstatefillerstep.cpp
    q2dviewer.cpp
    q2dviewerannotationhandler.cpp
    q2dviewerannotationsconfigurationscreen.cpp
    q2dviewerannotationsconfigurationscreenhelp.cpp
    q2dviewerannotationsconfigurationwidget.cpp
    q2dviewerannotationssettingshelper.cpp
    q2dviewerconfigurationscreen.cpp
    q2dviewerlayoutconfigurationscreen.cpp
    q2dviewerwidget.cpp
    q3dorientationmarker.cpp
    q3dviewer.cpp
    qcinecontroller.cpp
    qcolorspinbox.cpp
    qcolortransferfunctiongraphicalview.cpp
    qcolortransferfunctiongraphicalviewnode.cpp
    qcustomwindowleveldialog.cpp
    qcustomwindowleveleditwidget.cpp
    qdiagnosistest.cpp
    qdiagnosistestsresultsitem.cpp
    qdicomdumpbrowser.cpp
    qdpiconfigurationscreen.cpp
    qenhancedmenutoolbutton.cpp
    qexternalapplicationconfigurationscreen.cpp
    qfusionbalancewidget.cpp
    qfusionlayoutwidget.cpp
    qlayoutoptionswidget.cpp
    qlogviewer.cpp
    qmessageboxautoclose.cpp
    qmodalitiesselectorgroupbox.cpp
    qnotificationpopup.cpp
    qopacitytransferfunctiongraphicalview.cpp
    qopacitytransferfunctiongraphicalviewline.cpp
    qopacitytransferfunctiongraphicalviewnode.cpp
    qreleasenotes.cpp
    qscreendistribution.cpp
    qscrollareawithbettersizehint.cpp
    qthickslabwidget.cpp
    qtransferfunctioneditor.cpp
    qtransferfunctioneditor2.cpp
    qtransferfunctioneditorbygradient.cpp
    qtransferfunctioneditorbyvalues.cpp
    qtransferfunctiongraphicalview.cpp
    qtransferfunctionintervaleditor.cpp
    qtransferfunctionview.cpp
    qtreewidgetwithseparatorline.cpp
    qviewer.cpp
    qviewercinecontroller.cpp
    qviewercommand.cpp
    qviewerworkinprogresswidget.cpp
    qvoilutcombobox.cpp
    referencelinestool.cpp
    referencelinestooldata.cpp
    relativegeometrylayout.cpp
    renderqviewercommand.cpp
    repositorybase.cpp
    roidata.cpp
    roidataprinter.cpp
    roitool.cpp
    rotate3dtool.cpp
    rundiagnosistest.cpp
    screen.cpp
    screenlayout.cpp
    screenmanager.cpp
    screenshottool.cpp
    seedtool.cpp
    seedtooldata.cpp
    series.cpp
    settings.cpp
    settingsaccesslevelfilereader.cpp
    settingsinterface.cpp
    settingsparser.cpp
    settingsregistry.cpp
    shadewidget.cpp
    shortcutmanager.cpp
    shortcuts.cpp
    signaltosyncactionmapper.cpp
    singlesliceorvolumetricsynccriterion.cpp
    singlevolumedisplayunithandler.cpp
    slicehandler.cpp
    slicelocator.cpp
    sliceorientedvolumepixeldata.cpp
    slicingkeyboardtool.cpp
    slicingmousetool.cpp
    slicingtool.cpp
    slicingwheeltool.cpp
    sphereuniformpointcloudgenerator.cpp
    standardizeduptakevaluebodysurfaceareaformulacalculator.cpp
    standardizeduptakevaluebodyweightformulacalculator.cpp
    standardizeduptakevalueformula.cpp
    standardizeduptakevalueformulacalculator.cpp
    standardizeduptakevalueleanbodymassformulacalculator.cpp
    standarduptakevaluemeasurehandler.cpp
    starviewerapplication.cpp
    statswatcher.cpp
    stipplingvtkopenglpolydatamapper2d.cpp
    strokesegmentationmethod.cpp
    study.cpp
    studylayoutconfig.cpp
    studylayoutconfigsettingsconverter.cpp
    studylayoutconfigsettingsmanager.cpp
    studylayoutconfigsloader.cpp
    studylayoutmapper.cpp
    syncaction.cpp
    syncactionmanager.cpp
    syncactionmetadata.cpp
    syncactionsconfiguration.cpp
    syncactionsconfigurationhandler.cpp
    syncactionsconfigurationmenu.cpp
    synccriterion.cpp
    synchronizetool.cpp
    synchronizetooldata.cpp
    systeminformation.cpp
    systemrequirements.cpp
    systemrequirementstest.cpp
    temporaldimensionfillerstep.cpp
    thickslabsignaltosyncactionmapper.cpp
    thickslabsyncaction.cpp
    thumbnailcreator.cpp
    tool.cpp
    toolconfiguration.cpp
    tooldata.cpp
    toolmanager.cpp
    toolproxy.cpp
    toolregistry.cpp
    transdifferencetool.cpp
    transdifferencetooldata.cpp
    transferfunction.cpp
    transferfunctioneditor.cpp
    transferfunctioneditorcommands.cpp
    transferfunctionio.cpp
    transferfunctionmodel.cpp
    transferfunctionmodelfiller.cpp
    translatelefttool.cpp
    translatetool.cpp
    trilinearinterpolator.cpp
    viewerslayout.cpp
    viewerslayouttosyncactionmanageradapter.cpp
    viewpointgenerator.cpp
    voilut.cpp
    voiluthelper.cpp
    voilutpresetstool.cpp
    voilutpresetstooldata.cpp
    voilutsignaltosyncactionmapper.cpp
    voilutsyncaction.cpp
    volume.cpp
    volumebuilder.cpp
    volumebuilderfromcaptures.cpp
    volumedisplayunit.cpp
    volumedisplayunithandlerfactory.cpp
    volumefillerstep.cpp
    volumehelper.cpp
    volumepixeldata.cpp
    volumepixeldataiterator.cpp
    volumepixeldatareader.cpp
    volumepixeldatareaderfactory.cpp
    volumepixeldatareaderitkdcmtk.cpp
    volumepixeldatareaderitkgdcm.cpp
    volumepixeldatareadervtk.cpp
    volumepixeldatareadervtkdcmtk.cpp
    volumepixeldatareadervtkgdcm.cpp
    volumereader.cpp
    volumereaderjob.cpp
    volumereaderjobfactory.cpp
    volumereadermanager.cpp
    volumerepository.cpp
    voxel.cpp
    voxelindex.cpp
    voxelinformationtool.cpp
    voxelshader.cpp
    vtk4dlinearregressiongradientestimator.cpp
    vtkcorrectimageblend.cpp
    vtkdcmtkimagereader.cpp
    vtkimagedatacreator.cpp
    vtkimageextractphase.cpp
    vtkImageMapToWindowLevelColors3.cxx
    vtkimagereslicemapper2.cpp
    vtkRunThroughFilter.cxx
    windowlevel.cpp
    windowlevelfilter.cpp
    windowlevellefttool.cpp
    windowleveltool.cpp
    zoomfactorsignaltosyncactionmapper.cpp
    zoomfactorsyncaction.cpp
    zoomtool.cpp
    itkQtAdaptor.h  # needed so that it is found by automoc
)

if(WIN32)
    list(APPEND SOURCES
        windowssysteminformation.cpp
    )
elseif(UNIX AND NOT APPLE)
    list(APPEND SOURCES
        linuxsysteminformation.cpp
    )
endif()

set(FORMS
    q2dviewerannotationsconfigurationscreenbase.ui
    q2dviewerannotationsconfigurationscreenhelpbase.ui
    q2dviewerannotationsconfigurationwidgetbase.ui
    q2dviewerconfigurationscreenbase.ui
    q2dviewerlayoutconfigurationscreenbase.ui
    q2dviewerwidgetbase.ui
    qcinecontrollerbase.ui
    qcustomwindowleveldialogbase.ui
    qcustomwindowleveleditwidgetbase.ui
    qdiagnosistestbase.ui
    qdiagnosistestsresultsitembase.ui
    qdicomdumpbrowserbase.ui
    qdpiconfigurationscreenbase.ui
    qexternalapplicationconfigurationscreenbase.ui
    qfusionlayoutwidgetbase.ui
    qlayoutoptionswidgetbase.ui
    qlogviewerbase.ui
    qmodalitiesselectorgroupboxbase.ui
    qnotificationpopupbase.ui
    qreleasenotesbase.ui
    qthickslabwidgetbase.ui
    qtransferfunctioneditor2base.ui
    qtransferfunctioneditorbyvaluesbase.ui
    qtransferfunctiongraphicalviewbase.ui
    qtransferfunctionintervaleditorbase.ui
    qviewerworkinprogresswidget.ui
)

add_translations(QM_FILES core core)

add_library(core ${SOURCES} ${FORMS} ${QM_FILES})


################ Internal library dependencies ################

get_target_includes(EASYLOGGING_INCLUDES easylogging++ NO)
target_include_directories(core PRIVATE ${EASYLOGGING_INCLUDES})

target_link_libraries(core easylogging++)


################ External library dependencies ################

target_link_qt(core
    Concurrent
    Core
    Gui
    Network
    OpenGL
    Qml
    Quick
    QuickWidgets
    Widgets
    Xml
    XmlPatterns
)

target_link_vtk(core
    CommonCore
    CommonDataModel
    CommonExecutionModel
    CommonMath
    CommonTransforms
    FiltersCore
    FiltersGeneral
    FiltersSources
    GUISupportQt
    ImagingCore
    InteractionWidgets
    IOImage
    RenderingAnnotation
    RenderingCore
    RenderingImage
    RenderingOpenGL2
    RenderingVolume
    RenderingVolumeOpenGL2
)

target_link_dcmtk(core
    dcmdata
    dcmimage
    dcmimgle
    ofstd
)

find_package(ITK REQUIRED COMPONENTS
    ITKCommon
    ITKIODCMTK
    ITKIOGDCM
    ITKIOImageBase
    ITKRegionGrowing
    ITKSmoothing
    ITKStatistics
    ITKTransform
    ITKVTK
    ITKVtkGlue
)
set(ITK_NO_IO_FACTORY_REGISTER_MANAGER ON)
target_link_libraries(core ${ITK_LIBRARIES})

find_package(GDCM REQUIRED)
target_link_libraries(core gdcmCommon gdcmMSFF GDCM::vtkgdcm)

find_package(KF5ThreadWeaver REQUIRED)
target_link_libraries(core KF5::ThreadWeaver)

if(WIN32)
    target_link_libraries(core glu32.lib opengl32.lib wbemuuid.lib)
elseif(APPLE)
    target_link_libraries(core "-framework OpenGL")
elseif(UNIX)
    target_link_libraries(core GLU)
endif()
